

<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="python" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="python" > <!--<![endif]-->
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  <title>QUANTAXIS quantitative financial strategy framework &mdash; QUANTAXIS 1.0.39 documentation</title>
  

  
  
  
  

  

  
  
    

  

  
    <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" /> 

  
  <script src="../_static/js/modernizr.min.js"></script>

</head>

<body class="wy-body-for-nav">

   
  <div class="wy-grid-for-nav">

    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search">
          

          
            <a href="../index.html" class="icon icon-home"> QUANTAXIS
          

          
          </a>

          
            
            
              <div class="version">
                1.0.39
              </div>
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <!-- Local TOC -->
              <div class="local-toc"><ul>
<li><a class="reference internal" href="#">QUANTAXIS quantitative financial strategy framework</a><ul>
<li><a class="reference internal" href="#x-release-note">0.4.x Release Note</a></li>
</ul>
</li>
</ul>
</div>
            
          
        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../index.html">QUANTAXIS</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="../index.html">Docs</a> &raquo;</li>
        
      <li>QUANTAXIS quantitative financial strategy framework</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
            
            <a href="../_sources/QUANTAXIS_Trade/README.rst.txt" rel="nofollow"> View page source</a>
          
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <div class="section" id="quantaxis-quantitative-financial-strategy-framework">
<h1>QUANTAXIS quantitative financial strategy framework<a class="headerlink" href="#quantaxis-quantitative-financial-strategy-framework" title="Permalink to this headline">¶</a></h1>
<p>QUANTAXIS quantitative framework to achieve the stock and futures market, the whole species back to the test.Through the distributed crawler for data capture, to build a response to the data cleaning and market push engine to build a multi-language open response frame. And build interactive visualization of clients and websites.</p>
<a class="reference external image-reference" href="https://waffle.io/yutiansut/QUANTAXIS"><img alt="'Stories in Ready'" src="https://badge.waffle.io/yutiansut/QUANTAXIS.svg?label=ready&amp;title=Ready" /></a>
<div class="section" id="x-release-note">
<h2>0.4.x Release Note<a class="headerlink" href="#x-release-note" title="Permalink to this headline">¶</a></h2>
<p>QUANTAXIS Quantitative Financial Strategy Framework is a quantitative analysis solution for small and medium-sized strategy teams.We can quickly implement scene-oriented customization solutions with highly decoupled modularity and standardized protocols. QUANTAXIS is a progressive open Framework, you can according to their own needs, the introduction of their own data, analysis programs, visualization process, you can also RESTful interface, the rapid realization of multi-LAN / WAN collaboration.</p>
<p>QUANTAXIS and many excellent domestic quantitative platform is the difference, QA more concerned about the user experience and the actual situation, for the user needs will be more optimized, so will pay more attention to openness, the introduction of custom convenience, and the team Collaborative details are handled, such as custom data introductions, custom policy chart comparison, custom risk and policy portfolio management, and so on.</p>
<ul class="simple">
<li>Welcome group discussion: [group link] (<a class="reference external" href="https://jq.qq.com/?_wv=1027&amp;k=4CEKGzn">https://jq.qq.com/?_wv=1027&amp;k=4CEKGzn</a>)</li>
<li>For more information, see <a class="reference external" href="https://github.com/yutiansut/QUANTAXIS/blob/0.4-beta/update_log.md">https://github.com/yutiansut/QUANTAXIS/blob/0.4-beta/update_log.md</a></li>
<li>If you have any questions, you can send [issue] (<a class="reference external" href="https://github.com/yutiansut/QUANTAXIS/issues">https://github.com/yutiansut/QUANTAXIS/issues</a>) on github, or contact us at QQ 279336410, QQ group 563280067</li>
</ul>
<hr class="docutils" />
<p>More info on <a class="reference external" href="https://github.com/yutiansut/quantaxis">https://github.com/yutiansut/quantaxis</a></p>
<p>An EXAMPLE of QUANTAXIS BACKTEST like that below:</p>
<div class="code python highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">QUANTAXIS</span> <span class="k">as</span> <span class="nn">QA</span>
<span class="kn">from</span> <span class="nn">QUANTAXIS</span> <span class="k">import</span> <span class="n">QA_Backtest_stock_day</span> <span class="k">as</span> <span class="n">QB</span>


<span class="sd">&quot;&quot;&quot;</span>
<span class="sd">Written Before:</span>
<span class="sd">===============QUANTAXIS BACKTEST STOCK_DAY&#39;s Constant</span>
<span class="sd">Constant:</span>
<span class="sd">QB.account.message</span>
<span class="sd">QB.account.cash</span>
<span class="sd">QB.account.hold</span>
<span class="sd">QB.account.history</span>
<span class="sd">QB.account.assets</span>
<span class="sd">QB.account.detail</span>
<span class="sd">QB.account.init_assest</span>



<span class="sd">QB.strategy_stock_list</span>
<span class="sd">QB.strategy_start_date</span>
<span class="sd">QB.strategy_end_date</span>


<span class="sd">QB.today</span>

<span class="sd">QB.benchmark_code</span>




<span class="sd">Function:</span>
<span class="sd">get the market data (based on gap):</span>
<span class="sd">QB.QA_backtest_get_market_data(QB,code,QB.today)</span>
<span class="sd">get the market data as you want:</span>
<span class="sd">QA.QA_fetch_stock_day(code,start,end,model)</span>


<span class="sd">Order :</span>
<span class="sd">QB.QA_backtest_send_order(QB, code,amount,towards,order: dict)</span>

<span class="sd">order has three model:</span>
<span class="sd">1.Limited order order[&#39;order_model&#39;]=0 or l,L</span>
<span class="sd">attention: this model should have a order[&#39;price&#39;] key</span>
<span class="sd">order[&#39;price&#39;]=xxxx</span>

<span class="sd">2.Market order order[&#39;order_model&#39;]=1 or m,M,market,Market</span>
<span class="sd">3.Strict model order[&#39;order_model&#39;]=2 or s,S</span>
<span class="sd">    which is buy in the highest price or sell in the lowest price</span>

<span class="sd">Query the hold amount</span>

<span class="sd">QB.QA_backtest_hold_amount(QB,code)</span>


<span class="sd">&quot;&quot;&quot;</span>


<span class="nd">@QB</span><span class="o">.</span><span class="n">backtest_init</span>
<span class="k">def</span> <span class="nf">init</span><span class="p">():</span>
    <span class="c1">#</span>
    <span class="n">QB</span><span class="o">.</span><span class="n">setting</span><span class="o">.</span><span class="n">QA_util_sql_mongo_ip</span><span class="o">=</span><span class="s1">&#39;127.0.0.1&#39;</span>

    <span class="n">QB</span><span class="o">.</span><span class="n">account</span><span class="o">.</span><span class="n">init_assest</span><span class="o">=</span><span class="mi">2500000</span>
    <span class="n">QB</span><span class="o">.</span><span class="n">benchmark_code</span><span class="o">=</span><span class="s1">&#39;hs300&#39;</span>

    <span class="n">QB</span><span class="o">.</span><span class="n">strategy_stock_list</span><span class="o">=</span><span class="p">[</span><span class="s1">&#39;000001&#39;</span><span class="p">,</span><span class="s1">&#39;000002&#39;</span><span class="p">,</span><span class="s1">&#39;600010&#39;</span><span class="p">,</span><span class="s1">&#39;601801&#39;</span><span class="p">,</span><span class="s1">&#39;603111&#39;</span><span class="p">]</span>
    <span class="n">QB</span><span class="o">.</span><span class="n">strategy_start_date</span><span class="o">=</span><span class="s1">&#39;2017-03-01&#39;</span>
    <span class="n">QB</span><span class="o">.</span><span class="n">strategy_end_date</span><span class="o">=</span><span class="s1">&#39;2017-07-01&#39;</span>

<span class="nd">@QB</span><span class="o">.</span><span class="n">before_backtest</span>
<span class="k">def</span> <span class="nf">before_backtest</span><span class="p">():</span>
    <span class="k">global</span> <span class="n">risk_position</span>
    <span class="n">QA</span><span class="o">.</span><span class="n">QA_util_log_info</span><span class="p">(</span><span class="n">QB</span><span class="o">.</span><span class="n">account</span><span class="o">.</span><span class="n">message</span><span class="p">)</span>



<span class="nd">@QB</span><span class="o">.</span><span class="n">load_strategy</span>
<span class="k">def</span> <span class="nf">strategy</span><span class="p">():</span>
    <span class="c1">#print(QB.account.message)</span>
    <span class="c1">#print(QB.account.cash)</span>
    <span class="c1">#input()</span>

    <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">QB</span><span class="o">.</span><span class="n">strategy_stock_list</span><span class="p">:</span>
        <span class="n">QA</span><span class="o">.</span><span class="n">QA_util_log_info</span><span class="p">(</span><span class="n">QB</span><span class="o">.</span><span class="n">QA_backtest_get_market_data</span><span class="p">(</span><span class="n">QB</span><span class="p">,</span><span class="n">item</span><span class="p">,</span><span class="n">QB</span><span class="o">.</span><span class="n">today</span><span class="p">))</span>
        <span class="k">if</span> <span class="n">QB</span><span class="o">.</span><span class="n">QA_backtest_hold_amount</span><span class="p">(</span><span class="n">QB</span><span class="p">,</span><span class="n">item</span><span class="p">)</span><span class="o">==</span><span class="mi">0</span><span class="p">:</span>
            <span class="n">QB</span><span class="o">.</span><span class="n">QA_backtest_send_order</span><span class="p">(</span><span class="n">QB</span><span class="p">,</span><span class="n">item</span><span class="p">,</span><span class="mi">10000</span><span class="p">,</span><span class="mi">1</span><span class="p">,{</span><span class="s1">&#39;order_model&#39;</span><span class="p">:</span><span class="s1">&#39;Market&#39;</span><span class="p">})</span>


        <span class="k">else</span><span class="p">:</span>
            <span class="c1">#print(QB.QA_backtest_hold_amount(QB,item))</span>
            <span class="n">QB</span><span class="o">.</span><span class="n">QA_backtest_send_order</span><span class="p">(</span><span class="n">QB</span><span class="p">,</span><span class="n">item</span><span class="p">,</span><span class="mi">10000</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">,{</span><span class="s1">&#39;order_model&#39;</span><span class="p">:</span><span class="s1">&#39;Market&#39;</span><span class="p">})</span>

<span class="nd">@QB</span><span class="o">.</span><span class="n">end_backtest</span>
<span class="k">def</span> <span class="nf">after_backtest</span><span class="p">():</span>
    <span class="k">pass</span>
</pre></div>
</div>
</div>
</div>


           </div>
           
          </div>
          <footer>
  

  <hr/>

  <div role="contentinfo">
    <p>
        &copy; Copyright 2018, yutiansut.

    </p>
  </div>
  Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. 

</footer>

        </div>
      </div>

    </section>

  </div>
  


  

    <script type="text/javascript">
        var DOCUMENTATION_OPTIONS = {
            URL_ROOT:'../',
            VERSION:'1.0.39',
            LANGUAGE:'python',
            COLLAPSE_INDEX:false,
            FILE_SUFFIX:'.html',
            HAS_SOURCE:  true,
            SOURCELINK_SUFFIX: '.txt'
        };
    </script>
      <script type="text/javascript" src="../_static/jquery.js"></script>
      <script type="text/javascript" src="../_static/underscore.js"></script>
      <script type="text/javascript" src="../_static/doctools.js"></script>
      <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>

  

  
  
    <script type="text/javascript" src="../_static/js/theme.js"></script>
  

  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script> 

</body>
</html>